<?php

class UsersController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
    }
    
    public function updateUserAction(){
        $user = new Webservices_Users();
        $u = $user->getUser("admin", "123");
        $u = json_decode($u);
        $modelModelUser = new Application_Model_Users();
        
 
        $u = $modelModelUser->convertObjectToArray($u);
        $modelModelUser->convertField($u);
        
        echo $user->updateUser("admin", "123", json_encode($u));
        die;
    }

    public function indexAction() {
        $user = new Webservices_Users();
        Zend_Debug::dump($user->addUser('{"username":"Nguyen Van T","password":"123456","userId":0,"distance":10000}'));

//        Zend_Debug::dump($user->addFriend('admin', '123', '1'));
//        Zend_Debug::dump($user->getFriends('admin', 123));
//        $xmlUsers = $user->getUser('admin', '123');
//        Zend_Debug::dump($user->changeProfile('admin', '123456', $xmlUsers));        
        die;
    }
    
    public function addFriendAction(){
        $u = $this->_getParam('u');
        $p = $this->_getParam('p');
        $userId = $this->_getParam('user-id');
        
        $user = new Webservices_Users();
        Zend_Debug::dump($user->addFriend($u, $p, $userId));
        die;
    }
    
    public function changeProfileAction(){
        $user = new Webservices_Users();
        Zend_Debug::dump($user->addFriend($u, $p, $userId));
        die;
    }
    
    public function findUserAction(){
        $u = $this->_getParam('u');
        $p = $this->_getParam('p');
        $name = $this->_getParam('name');
        
        $user = new Webservices_Users();
        Zend_Debug::dump($user->findUser($u, $p, $name));
        die;
    }
    
    public function addUserAction(){
        $user = new Webservices_Users();
        Zend_Debug::dump($user->addUser("<hipro.entities.Users><username>1233</username><password>123456</password><userId>0</userId><distance>10000</distance></hipro.entities.Users>"));
        die;
    }
    
    public function getUserByUsernameAction(){
        $user = new Webservices_Users();
        Zend_Debug::dump($user->getUserByUsername("admin"));
        die;
    }

}




